<!DOCTYPE html>
<html lang="ch" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="copyright" content="本页版权 www.zongheng.com 纵横中文网所有。All Rights Reserved"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>小说_小说推荐_好看的完本免费小说推荐- 纵横中文网</title>
    <meta name="keywords" content="书库，热门小说书库，连载小说书库，全本小说书库，书库更新列表，纵横中文网书库。"/>
    <meta name="description" content="纵横中文网小说书库，提供最新小说在线阅读，最新小说TXT下载，经典完本小说，包括奇幻小说，玄幻小说，言情小说，都市小说等各类小说尽在纵横中文网小说书库。"/>


    <div th:include="mobile/common/css :: css"></div>

    <style type="text/css">


        .line-limit-length {

            overflow: hidden;

            text-overflow: ellipsis;

            white-space: nowrap;

        }

        .indexP p a {
            color: #4c6978;
        }

        .Readarea {
            font-size: 18px;
            line-height: 35px;
            padding: 10px;
            color: #333;
        }

        div, p {
            wrap-work: break-word;
            word-break: break-all;
            word-wrap: break-word;
            word-break: normal;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -ms-box-sizing: border-box;
        }

        .indexDiv a {
            margin-left: 20px;
        }

        img {
            width: 130px;
            height: 180px;
        }
        .text-three-line{
            /*文字显示3行 超出部分缩略号*/
            text-overflow: -o-ellipsis-lastline;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
    </style>
</head>
<body>

<div style="height: 50px;line-height: 50px;text-align: center" class="layui-header header header-doc  layui-bg-cyan">

    <div style="float: left;margin-left: 10px">
        <a href="javascript:history.go(-1)">
            <i style="font-size: 20px;color: #fff;" class="layui-icon">&#xe65c;</i></a>
    </div>
    <b class="layui-icon">小说列表</b>
    <div style="float: right;margin-right: 10px">
        <a th:href="@{/}"><i style="font-size: 20px;color: #fff;" class="layui-icon">&#xe68e;</i></a>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row">

        <div class="layui-col-xs10 layui-col-sm10 layui-col-md11 layui-col-lg11" style="padding-top:1%">
            <input id="title" type="text" name="title" required lay-verify="required" placeholder="请输入书名·作者"
                   autocomplete="off"
                   class="layui-input" th:value="${keyword}">
        </div>
        <div class="layui-col-xs1" style="padding: 1%">
            <button onclick="search(1,20)" class="layui-btn" lay-submit lay-filter="formDemo">搜索</button>
        </div>
    </div>

</div>

<div id="bookList">
    <div class="layui-row" style="margin-bottom:10px;padding:10px;background: #f2f2f2" th:each="item,status : ${data.results}">
        <a th:href="@{'/bookdetail/'+${item.id}}">
            <div class="layui-col-xs6 layui-col-sm3 layui-col-md2 layui-col-lg2" style="text-align: center">
                <img style='width: 130px;height: 180px' align="center"
                     th:src="${item.imgUrl}" src="http://www.shuquge.com/files/article/image/86/86786/86786s.jpg"/>

            </div>
        </a>
        <div style="padding: 10px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8">
            <a th:href="@{'/bookdetail/'+${item.id}}">
                <div class="line-limit-length" style=";color: #000;font-size: 15px">[[${item.bookName}]]</div>
            </a>
            <div style=";color: #4c6978;float: right;"><i style="color: red"></i></div>
            <a th:href="@{'/bookdetail/'+${item.id}}">
                <div style=";color: #a6a6a6;" class="line-limit-length">作者：[[${item.author}]]</div>
            </a>
            <div style="margin-top: 5px;color: #a6a6a6;">类别：[[${item.typeName}]]</div>
            <div style="margin-top: 5px;color: #a6a6a6;">状态：[[${item.state}]]</div>
            <div style="margin-top: 5px;color: #a6a6a6;">更新时间：<i style='color: red'>[[${item.updateTime}]] </i>
            </div>
            <div class="text-three-line" style="margin-top: 5px;color: #a6a6a6;">简介：[[${item.bookDesc}]]</div>
            <div style="margin-top: 5px;color: #a6a6a6;" th:if="${item.cacheStatus == 1}"><button th:onclick="|downloadBook(${item.id})|">下载本书</button></div>

        </div>

    </div>

</div>

<!-- 分页 -->
<div style="text-align: center">
    <div id="page"></div>
</div>
<div th:replace="mobile/common/footer :: footer"></div>

<a name="buttom"></a>
</body>

<div th:replace="mobile/common/js :: js"></div>

<script type="text/javascript" th:inline="javaScript">
    let webPath=/*[[@{/}]]*/'';

    let sortBy = getQueryVariable("sortBy");
    let keyword = getQueryVariable("keyword");

    let pSize = 10;

    if(keyword != false){
        $("#title").val(decodeURI(keyword));
    }else{
        keyword = "";
    }

    var viewType = [[${viewType}]];
    //layui分页
    layui.use('laypage', function () {
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'page'
            , loading: true
            , limits: [10, 20, 30, 50]
            , count: [[${data.paging.totalNumber}]]
            , curr: [[${data.paging.pageNumber}]]
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            , limit: [[${data.paging.pageSize}]]
            , jump: function (obj, first) {
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                //首次不执行
                if (!first) {
                    queryByAllCondition(obj.curr, obj.limit);
                }
            }
        })
    });
    //分页传参
    function queryByAllCondition(curr, limit) {
        let toUrl = webPath + "/booklist?type="+[[${type}]]+"&viewType="+viewType+"&pageNumber=" + curr + "&pageSize=" + limit;
        window.location.href = toUrl;
    }

    //search(1,pSize);

    /*function search(curr,limit) {
        keyword = $("#title").val();
        var searchData = {
            paging: {
                pageNumber: curr,
                pageSize: pSize,
            },
            parameters: {
                bookName: keyword,
            }
        };
        let bookListUrl = webPath + "/searchByPage";
        $.ajax({
            type: "post",
            url: bookListUrl,
            data: JSON.stringify(searchData),
            dataType: "json",
            contentType: "application/json",
            success: function (data) {
                if (data.code == 10000) {
                    var bookList = data.data.results;
                    var bookListHtml = "";
                    for (var i = 0; i < bookList.length; i++) {
                        var book = bookList[i];

                        /!*var end = book.bookDesc.indexOf("<");
                        if(end != -1) {
                            book.bookDesc = book.bookDesc.substring(0,end);
                        }*!/

                        if(book.bookDesc){
                            book.bookDesc = book.bookDesc.replace(/<[^>]+>/g,"").replace(/\s+/g,"").replace(/&nbsp;/g,"");
                        }

                        bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
                            "        <a href=\"/book/bookdetail/"+book.id+"\">\n" +
                            "            <div class=\"layui-col-xs6 layui-col-sm3 layui-col-md2 layui-col-lg2\" style=\"text-align: center\">\n" +
                            "                <img style='width: 130px;height: 180px' align=\"center\"\n" +
                            "                     src=\""+book.imgUrl+"\"/>\n" +
                            "\n" +
                            "            </div>\n" +
                            "        </a>\n" +
                            "        <div style=\"padding: 10px\" class=\"layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8\">\n" +
                            "            <a href=\"/book/bookdetail/"+book.id+"\">\n" +
                            "                <div class=\"line-limit-length\" style=\";color: #000;font-size: 15px\">"+book.bookName+"</div>\n" +
                            "            </a>\n" +
                            "            <div style=\";color: #4c6978;float: right;\"><i style=\"color: red\"></i></div>\n" +
                            "            <a href=\"/book/bookdetail/"+book.id+"\">\n" +
                            "                <div style=\";color: #a6a6a6;\" class=\"line-limit-length\">作者："+book.author+"</div>\n" +
                            "            </a>\n" +
                            "            <div style=\"margin-top: 5px;color: #a6a6a6;\">类别："+book.typeName+"</div>\n" +
                            "            <div style=\"margin-top: 5px;color: #a6a6a6;\">状态："+(book.state!=null?'连载':'完结')+"</div>\n" +
                            "            <div style=\"margin-top: 5px;color: #a6a6a6;\">更新时间：<i style='color: red'>"+book.updateTime.substr(0,11)+"</i>\n" +
                            "            </div>\n" +
                            "            <div style=\"margin-top: 5px;color: #a6a6a6;\">简介："+(book.bookDesc?(book.bookDesc.length>15?(book.bookDesc.substr(0,15)+"..."):book.bookDesc):book.bookDesc)+"</div>\n" +
                            "            <div style=\"margin-top: 5px;color: #a6a6a6;\"><a href='#' onclick='downloadBook("+book.id+",\""+book.bookName+"\")'>下载本书</div>\n" +
                            "\n" +
                            "\n" +
                            "        </div>\n" +
                            "\n" +
                            "    </div>");
                    }
                    $("#bookList").html(bookListHtml);

                    layui.use('laypage', function () {
                        var laypage = layui.laypage;

                        //执行一个laypage实例
                        laypage.render({
                            elem: 'books' //注意，这里的 test1 是 ID，不用加 # 号
                            , count: data.data.total //数据总数，从服务端得到,
                            , curr: data.data.pageNum
                            , limit: data.data.pageSize
                            , jump: function (obj, first) {


                                //obj包含了当前分页的所有参数，比如：
                                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                                console.log(obj.limit); //得到每页显示的条数


                                //首次不执行
                                if (!first) {
                                    search(obj.curr, obj.limit);
                                } else {

                                }
                            }
                        });
                    });
                } else {
                    layer.alert(data.msg);
                }

            },
            error: function () {
                layer.alert('网络异常');
            }
        })

    }*/


    function searchByAllCondition(curr, limit, newKeyword) {
        var toUrl = "/book/search?curr=" + curr + "&limit=" + limit;
        var ids = $("#ids").val();
        if (ids) {
            toUrl += ("&historyBookIds=" + ids);
        }
        var token = $("#token").val();
        if (token) {
            toUrl += ("&token=" + token);
        }
        var keyword = $("#keyword").val();
        if (newKeyword) {
            toUrl += encodeURI("&keyword=" + newKeyword);
        } else if (keyword) {
            toUrl += encodeURI("&keyword=" + keyword);
        }
        var bookStatus = $("#bookStatus").val();
        if (bookStatus) {
            toUrl += ("&bookStatus=" + bookStatus);
        }
        var catId = $("#catId").val();
        if (catId) {
            toUrl += ("&catId=" + catId);
        }

        var sortBy = $("#sortBy").val();
        if (sortBy) {
            toUrl += ("&sortBy=" + sortBy);
        }

        var sort = $("#sort").val();
        if (sort) {
            toUrl += ("&sort=" + sort);
        }

        window.location.href = toUrl;
    }

    function searchBooks() {
        var keywords = $("#title").val();
        $("#keyword").val("");
        searchByAllCondition(1, 20, keywords);
    }

    function downloadBook(bookId){
        var fileUrl = webPath + '/bookfile/download?id='+bookId;
        location.href = fileUrl;

        /*var xhr = new XMLHttpRequest();
        xhr.open('GET', fileUrl, true);    // 也可以使用POST方式，根据接口
        xhr.responseType = "blob";  // 返回类型blob
        // 定义请求完成的处理函数，请求前也可以增加加载框/禁用下载按钮逻辑
        xhr.onload = function () {
            // 请求完成
            if (this.status === 200) {
                // 返回200
                var blob = this.response;
                var reader = new FileReader();
                reader.readAsDataURL(blob);  // 转换为base64，可以直接放入a表情href
                reader.onload = function (e) {
                    // 转换完成，创建一个a标签用于下载
                    var a = document.createElement('a');
                    a.download = bookName + ".txt"
                    a.href = e.target.result;
                    $("body").append(a);  // 修复firefox中无法触发click
                    a.click();
                    $(a).remove();
                }
            } else {
                alert();
            }
        };
        // 发送ajax请求
        xhr.send()*/
    }

</script>
<script>




    function toMyCollect() {
        var token = localStorage.getItem("token");
        if (token) {
            window.location.href = "/book/search?token=" + token;
        } else {
            window.location.href = "/user/login.html";
        }
    }
</script>


</html>